﻿Imports System.Data.OleDb
Public Class RateDishes
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

    End Sub

    Protected Sub btn_saveR_Click(ByVal sender As Object, ByVal e As EventArgs) Handles btn_saveR.Click

        Dim oledbConn = New OleDbConnection(ConfigurationManager.ConnectionStrings("JamaicanConnectionString").ConnectionString)
        oledbConn.Open()
        Dim delPrevRatings = "DELETE FROM MemberRatingDishes WHERE Rater =@j1 AND DishID=@j2"
        Dim oleDbCmd2 = New OleDbCommand(delPrevRatings, oledbConn)
        oleDbCmd2.Parameters.AddWithValue("@j1", User.Identity.Name)
        oleDbCmd2.Parameters.AddWithValue("@j2", Request.Params("ID"))
        oleDbCmd2.ExecuteNonQuery()


        Dim sql = "INSERT INTO MemberRatingDishes (Rating,Rater,DishID) VALUES (@j1,@j2,@j3)"
        Dim oleDbCmd = New OleDbCommand(sql, oledbConn)

        oleDbCmd.Parameters.AddWithValue("@j1", Rating1.CurrentRating)
        oleDbCmd.Parameters.AddWithValue("@j2", User.Identity.Name)
        oleDbCmd.Parameters.AddWithValue("@j3", Request.Params("ID"))
        oleDbCmd.ExecuteNonQuery()
        oledbConn.Close()
        oleDbCmd.Dispose()
        oledbConn.Dispose()


    End Sub
End Class